<?php
namespace app\common\controller;
use think\Controller;
class All extends Controller{
	public function _initialize(){
		$this->url = strtolower($this->request->module() . '/' . $this->request->controller() . '/' . $this->request->action());
		$this->model = strtolower($this->request->module() . '/' . $this->request->controller());		
		$this->assign(config());
	}	
	//全局标签定义
    protected function Lable_Style(){
		$zanpiancms = $GLOBALS['config']['site'];
		$zanpiancms['site_hotkeywords'] =$GLOBALS['config']['site']['site_hotkeywords'];
		$zanpiancms['site_domain']=strtolower($this->request->server('HTTP_HOST'));
		$zanpiancms['model'] = strtolower($this->request->module());
		$zanpiancms['controller'] = strtolower($this->request->controller());
		$zanpiancms['action'] = strtolower($this->request->action());
		$zanpiancms['route'] = strtolower(request()->module()).'/'.strtolower(request()->controller()).'/'.strtolower(request()->action());
		$zanpiancms['site_path'] = URL_PATH;
		$zanpiancms['site_public'] = TPL_PATH;
		$zanpiancms['site_path_ads'] = $GLOBALS['config']['system']['system_adsfile'];
		$zanpiancms['list_language'] = explode(',',$GLOBALS['config']['video']['video_language']);
		$zanpiancms['list_year'] = explode(',',$GLOBALS['config']['video']['video_year']);
		$zanpiancms['list_order'] = array('addtime','hits','gold');	
        $zanpiancms['list_area'] = F('_data/list_area');
        $zanpiancms['list_week'] = $this->parse('textarea',$GLOBALS['config']['setting']['week_list']);			
		$zanpiancms['list_letter'] = explode(',','A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z,0-9');
		$zanpiancms['list_position'] = $this->parse('textarea',$GLOBALS['config']['setting']['document_position']);
		$zanpiancms['list_week'] = $this->parse('textarea',$GLOBALS['config']['setting']['week_list']);
		$zanpiancms['tpl_id'] = $this->parse('textarea',$GLOBALS['config']['setting']['tpl_id']);	
        $GLOBALS['route']=$zanpiancms['route'];
        $this->assign($zanpiancms);
    }
	function parse($type, $value){
		if($value){
		    switch ($type) {
			    case 'textarea': //解析数组
			    $array = preg_split('/[,;\r\n]+/', trim($value, ",;\r\n"));
			    if(strpos($value,':')){
				    $value  = array();
				        foreach ($array as $val) {
					    $list = explode(':', $val);
					    if(isset($list[2])){
						    $value[$list[0]]   = $list[1].','.$list[2];
					    }else{
						$value[$list[0]]   = $list[1];
					   }
				    }
			    }else{
				$value =    $array;
			    }
			     break;
		    }
		}
		return $value;
	}	
}
?>